#include <bits/stdc++.h>
using namespace std;

const int N = 4e6 + 5;

int t;
int n;

char s[N];

int a[10]; // 00 01 11 10

inline void transfront(int id, int x[])
{
    if (id < 2)
        --x[0];
    else
        --x[2];
}

inline void transback(int id, int x[])
{
    if (id == 0 || id == 3)
        --x[1];
    else
        --x[3];
}

inline bool checkfuther1(int a[]) {
    a[0] = 0;
    if (a[1]) a[2] = 0;
    int x = min(a[1], a[3]);
    a[1] -= x;
    a[3] -= x;
    return (a[0] + a[1] + a[2] + a[3]) == 0;
}

inline bool checkfuther2(int a[]) {
    a[0] = 0;
    if (a[1]) a[2] = 0;
    return (a[0] + a[2] == 0) && (a[1] == a[3] + 1);
    
}

inline int check(int a[])
{
    for (int i = 0; i < 4; ++i)
        for (int j = 0; j < 4; ++j)
        {
            int b[4] = {a[0], a[1], a[2], a[3]};
            if (b[i] == 0 || b[j] == 0) continue;
            int res = -1;
            if ((i==0 && j==0) || (i==0 && j == 1) || (i==3 && j==0) || (i==3 && j==1)) {
                --b[i]; --b[j];
                // printf("b-> %d %d %d %d\n", b[0], b[1], b[2] ,b[3]);
                res = checkfuther1(b) ? i * 4 + j : -1;
            } else if ((i==1 && j==2) || (i==1 && j==3) || (i==2 && j==2) || (i==2 && j==3)) {
                --b[i]; --b[j];
                swap(b[0], b[2]);
                swap(b[1], b[3]);
                // printf("b-> %d %d %d %d\n", b[0], b[1], b[2] ,b[3]);
                res = checkfuther1(b) ? i * 4 + j : -1;
            } else if ((i==0 && j==3) || (i==0 && j==2) || (i==3 && j==3) || (i==3 && j==2)) {
                --b[i]; --b[j];
                // printf("b-> %d %d %d %d\n", b[0], b[1], b[2] ,b[3]);
                res = checkfuther2(b) ? i * 4 + j : -1;
            } else {
                --b[i]; --b[j];
                swap(b[0], b[2]);
                swap(b[1], b[3]);
                // printf("b-> %d %d %d %d\n", b[0], b[1], b[2] ,b[3]);
                res = checkfuther2(b) ? i * 4 + j : -1;
            }
            if (~res) {
                // printf("res->%d\n", res);
                return true;
            }
        }
    return -1;
}

vector<int> pos[4];

char *dat[N];

set<string> S[2];

int main(int argc, char const *argv[])
{
    scanf("%d", &t);
    for (int kk = 0; kk < t; ++kk)
    {
        for (int i=0; i<n; ++i) {
            // delete dat[i];
            free(dat[i]);
        }
        S[0].clear();
        S[1].clear();
        scanf("%d", &n);
        memset(a, 0, sizeof a);
        for (int i = 0; i < 4; ++i)
            pos[i].clear();
        
        for (int i=0; i<n; ++i) {
            scanf("%s", s);
            int len = strlen(s);
            // dat[i] = new char[len+1];
            dat[i] = (char*)malloc(len + 1);
            strcpy(dat[i], s);
            if (s[0] == '0' && s[len-1] == '1') {
                S[0].insert(string(s));
            } else if (s[0] == '1' && s[len-1] == '0') {
                reverse(s, s+len);
                S[1].insert(string(s));
            }
        }
        for (int i = 0; i < n; ++i)
        {
            char *s = dat[i];
            // printf("s[%d]->%s\n", i, s);
            char first = s[0], last = s[strlen(s) - 1];
            // printf("%c %c\n", first, last);
            if (first == '0' && last == '0')
            {
                // printf("%d -> %d\n", i, 0);
                ++a[0];
                pos[0].push_back(i);
            }
            else if (first == '0' && last == '1')
            {
                // printf("%d -> %d\n", i, 1);
                ++a[1];
                if (S[1].count(string(dat[i]))) continue;
                pos[1].push_back(i);
            }
            else if (first == '1' && last == '1')
            {
                // printf("%d -> %d\n", i, 2);
                ++a[2];
                pos[2].push_back(i);
            }
            else
            {
                // printf("%d -> %d\n", i, 3);
                string s(dat[i]);
                reverse(s.begin(), s.end());
                
                ++a[3];
                if (S[0].count(s)) continue;
                pos[3].push_back(i);
            }
        }

        int ans = 0x7fffffff;
        int method = 0, res;
        // printf("a-> %d %d %d %d\n", a[0], a[1], a[2], a[3]);

        for (int i = 0; i <= pos[1].size(); ++i)
        {
            int b[4] = {a[0], a[1], a[2], a[3]};
            b[1] -= i;
            b[3] += i;
            int res = -1;
            if (~(res = check(b)))
            {
                // printf("1 %d\n", i);
                ans = min(ans, i);
                method = i;
                break;
            }
        }
        int ed = min(ans-1, (int)pos[3].size());
        for (int i = 0; i <= ed; ++i)
        {
            int b[4] = {a[0], a[1], a[2], a[3]};
            b[1] += i;
            b[3] -= i;
            if (~(res = check(b)))
            {
                ans = min(ans, i);
                method = -i;
                break;
            }
        }
        if (ans == 0x7fffffff) {
            puts("-1");
            continue;
        }
        printf("%d\n", ans);
        // printf("method -> %d\n", method);
        if (method > 0) {
            for (int i=0; i<ans; ++i) {
                printf("%d%c", pos[1][i]+1, i==ans-1? '\n':' ');
            }
        } else if (method < 0) {
            for (int i=0; i<ans; ++i) {
                printf("%d%c", pos[3][i]+1, i==ans-1? '\n':' ');
            }
        }
    }
    return 0;
}
